import { formatNumber } from "@/utils/util";
const normal_option = {
  dataset: {
    // 用 dimensions 指定了维度的顺序。直角坐标系中，
    // 默认把第一个维度映射到 X 轴上，第二个维度映射到 Y 轴上。
    // 如果不指定 dimensions，也可以通过指定 series.encode
    dimensions: [],
    source: [],
  },
  grid: {
    left: "10%",
    right: 20,
  },
  legend: {
    show: false,
  },
  tooltip: {
    show: true,
    // formatter: '{b}: {c}'
    formatter: function (params) {
      let { seriesType, seriesIndex } = params;
      if (["line", "bar"].includes(seriesType)) {
        let [xField, ...yField] = params.dimensionNames;
        let currentLabel = params.value[xField];
        let currentValue = formatNumber(params.value[yField[seriesIndex]]);
        return `${currentLabel}: ${currentValue}`;
      }

      if (seriesType === "pie") {
        let currentLabel = params.value[params.seriesName];
        let currentValue = formatNumber(params.value["tooltip_value"]);
        return `${currentLabel}: ${currentValue}`;
      }

      if (seriesType === "graph") {
        let currentLabel = params.data["name"];
        let currentValue = formatNumber(params.data["value"]);
        return `${currentLabel}: ${currentValue}`;
      }
    },
    confine: true,
    extraCssText: "max-width:300px; white-space:pre-wrap; word-break:break-all",
  },
  animation: true,
};

export { normal_option };
